/*    */ package com.cr.quartz.util;
/*    */ 
/*    */ import com.cr.common.utils.MyDateUtils;
/*    */ import java.text.ParseException;
/*    */ import java.util.ArrayList;
/*    */ import java.util.Date;
/*    */ import java.util.List;
/*    */ import org.quartz.CronExpression;
/*    */ import org.quartz.TriggerUtils;
/*    */ import org.quartz.impl.triggers.CronTriggerImpl;
/*    */ import org.quartz.spi.OperableTrigger;
/*    */ 
/*    */ public class CronUtils {
/*    */   public static boolean isValid(String cronExpression) {
/* 28 */     return CronExpression.isValidExpression(cronExpression);
/*    */   }
/*    */   
/*    */   public static String getInvalidMessage(String cronExpression) {
/*    */     try {
/* 41 */       new CronExpression(cronExpression);
/* 42 */       return null;
/* 44 */     } catch (ParseException pe) {
/* 46 */       return pe.getMessage();
/*    */     } 
/*    */   }
/*    */   
/*    */   public static Date getNextExecution(String cronExpression) {
/*    */     try {
/* 60 */       CronExpression cron = new CronExpression(cronExpression);
/* 61 */       return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis()));
/* 63 */     } catch (ParseException e) {
/* 65 */       throw new IllegalArgumentException(e.getMessage());
/*    */     } 
/*    */   }
/*    */   
/*    */   public static List<String> getRecentTriggerTime(String cron) {
/* 77 */     List<String> list = new ArrayList<>();
/*    */     try {
/* 80 */       CronTriggerImpl cronTriggerImpl = new CronTriggerImpl();
/* 81 */       cronTriggerImpl.setCronExpression(cron);
/* 82 */       List<Date> dates = TriggerUtils.computeFireTimes((OperableTrigger)cronTriggerImpl, null, 10);
/* 83 */       for (Date date : dates)
/* 85 */         list.add(MyDateUtils.parseDateToStr(MyDateUtils.YYYY_MM_DD_HH_MM_SS, date));
/* 88 */     } catch (ParseException e) {
/* 90 */       return null;
/*    */     } 
/* 92 */     return list;
/*    */   }
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-quartz-4.7.0.jar!\com\cr\quart\\util\CronUtils.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */